﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using XukaShop.Dao;
using XukaShop.Models.Entities;

namespace XukaShop.Biz
{
    public class BrandBiz
    {
        private BrandDao _brandDao = new BrandDao();

        /// <summary>
        /// Convert string value to Brand object
        /// </summary>
        /// <param name="brandName">Name of brand</param>
        /// <param name="isDelete">Is Delete or not</param>
        /// <returns></returns>
        public Brand ConvertToBrandObject(string brandName, int brandId = 0, bool isDelete = false)
        {
            Brand brandObj = new Brand();
            brandObj.Id = brandId;
            brandObj.BrandName = brandName;
            brandObj.IsDeleted = isDelete;
            return brandObj;
        }
        /// <summary>
        /// Get List Product Brand in Database
        /// </summary>
        /// <returns></returns>
        public List<Brand> GetListBrands()
        {
            return _brandDao.GetListBrands();
        }

        /// <summary>
        /// Get a Product Brand by Id
        /// </summary>
        /// <param name="brandId"></param>
        /// <returns></returns>
        public Brand GetBrandById(int brandId)
        {
            return _brandDao.GetBrandById(brandId);
        }

        /// <summary>
        /// Edit a Product Brand
        /// </summary>
        /// <param name="brandModel"></param>
        /// <returns></returns>
        public bool EditBrand(Brand brandModel)
        {
            return _brandDao.EditBrand(brandModel);
        }

        /// <summary>
        /// Create a Product Brand
        /// </summary>
        /// <param name="brandModel"></param>
        /// <returns></returns>
        public bool CreateBrand(Brand brandModel)
        {
            return _brandDao.CreateBrand(brandModel);
        }

        /// <summary>
        /// Delete a Product Brand
        /// </summary>
        /// <param name="brandId"></param>
        /// <returns>Id of brand</returns>
        public bool DeleteBrand(int brandId)
        {
            return _brandDao.DeleteBrand(brandId);
        }

        /// <summary>
        /// Check Brand is existed nor not
        /// </summary>
        /// <param name="brandName"></param>
        /// <param name="isUpdateMode">Check when Update or Create</param>
        /// <param name="brandId"></param>
        /// <returns></returns>
        public bool IsExistedBrand(string brandName, bool isUpdateMode, int brandId = 0)
        {
            return _brandDao.IsExistedBrand(brandName, isUpdateMode, brandId);
        }
    }
}